#include "CameraManager.h"

namespace PeanutQuest {

	CameraManager::CameraManager() : cg::Entity("CameraManager"){
	}
	CameraManager::~CameraManager() {
	}

	void CameraManager::init() {
		actualCamera = "FirstCamera";
		v = (cg::View*)cg::Registry::instance()->get("view");
	}

	/*BASTA UMA FUNCAO PARA  MUDAR DE CAMARA*/
	void CameraManager::changeCamera_to_FirstCamera() {
		if(actualCamera != "FirstCamera"){
			v->unlinkEntity(actualCamera);
			v->linkEntityAtBeginning("FirstCamera");
			if(actualCamera == "FreeCamera") {
				handleFreeCamera();
			}
			actualCamera = "FirstCamera";
		}
	}

	void CameraManager::changeCamera_to_ThirdCamera() {
		if(actualCamera != "ThirdCamera"){
			v->unlinkEntity(actualCamera);
			v->linkEntityAtBeginning("ThirdCamera");
			if(actualCamera == "FreeCamera") {
				handleFreeCamera();
			}
			actualCamera = "ThirdCamera";
		}
	}

	void CameraManager::changeCamera_to_DebugCamera() {
		if(actualCamera != "FreeCamera"){
			v->unlinkEntity(actualCamera);
			v->linkEntityAtBeginning("FreeCamera");
			handleFreeCamera();
			actualCamera = "FreeCamera";
		}
	}

	void CameraManager::handleFreeCamera() {
		FreeCamera *fc = (FreeCamera*)cg::Registry::instance()->get("FreeCamera");
			fc->turnActive();
	}

}